require  'java'

module JavaSql
  include_package 'java.sql'
end

include_class("java.lang.Class") 
include_class("java.lang.ClassNotFoundException")
begin
  Java::JavaClass.for_name("org.apache.derby.jdbc.EmbeddedDriver")
  connection = JavaSql::DriverManager.getConnection("jdbc:derby:VotingDB;create=true", 
                  "", 
                  "")
rescue ClassNotFoundException
  puts "ClassNotFoundException"
rescue JavaSql::SQLException
  puts "SQLException"
end

statem = connection.createStatement()
response = statem.executeQuery("create table VOTINGTABLES(id varchar(40),num integer,candidateName varchar(50), totalVotes integer)")

while (response.next())
  puts response.getString("NAME") + " => " +response.getString("POSITION")
end